package com.example.controller;

import com.example.pojo.Email;
import com.example.util.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/msg/email")
public class EmailController {

    @Autowired
    private EmailService emailService;

    @RequestMapping(value = "/send")
    public String sendEmail(Email email) {
        try {
            emailService.sendTextMail(email.getRecipientAddress(), email.getSubject(), email.getContent());
            return "OK";
        } catch (Exception e) {
            e.printStackTrace();
            return "OK";
        }
    }

}
